package com.cskaoyan.dbutils;

import com.cskaoyan.datasource.opensource.DruidUtils;
import com.cskaoyan.dbutils.impl.MyResultSetHandler;
import com.mysql.jdbc.JDBC4Connection;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/06/05 17:36
 *
 * @author ciggar
 *
 * BeanHandler
 */
public class DBUtilsDemo3 {


    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner ， 传入数据库连接池
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        Cskaoyan cskaoyan = queryRunner.query("select id,teacher_name as teacherName,money,nickname from cskaoyan where id = ?",
                new BeanHandler<>(Cskaoyan.class), 1001);


        System.out.println(cskaoyan);

    }
}
